const Router = require('koa-router');

//控制器
const { login, getInfo, updateInfo } = require('../controller/user.controller');

//中间件
const { auth } = require('../middleware/auth.middleware');
const { validator } = require('../middleware/validator.middleware');

//实例化router对象
const router = new Router({ prefix: '/user' });

//登录接口
router.post('/login', login);

//获取用户信息接口
router.get('/getInfo', auth, getInfo);

//更改用户信息接口
router.patch('/updateInfo', auth, validator({ user_age: { type: 'number', required: false }, user_name: { type: 'string', required: false }, user_sex: { type: 'string', required: false } }), updateInfo);

module.exports = router;